﻿using System;
using System.Collections.Generic;
using System.Linq;
using Character;
using SEXY;
using UnityEngine;

namespace Studio
{
	// Token: 0x0200043D RID: 1085
	public class ChaControl
	{
		// Token: 0x06001AFA RID: 6906 RVA: 0x000ABD98 File Offset: 0x000A9F98
		public ChaControl(Human _human, CharFileStatus _status)
		{
			this.human = _human;
			this.fileStatus = ((_status != null) ? _status : new CharFileStatus());
			this.dicClothesID = new Dictionary<int, WEAR_SHOW_TYPE[]>();
			this.dicClothesID[0] = new WEAR_SHOW_TYPE[1];
			this.dicClothesID[1] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.TOPLOWER,
				WEAR_SHOW_TYPE.BOTTOM
			};
			this.dicClothesID[2] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.BRA
			};
			this.dicClothesID[3] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SHORTS
			};
			this.dicClothesID[4] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SWIMUPPER
			};
			this.dicClothesID[5] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SWIMLOWER
			};
			this.dicClothesID[6] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SWIM_TOPUPPER
			};
			this.dicClothesID[7] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SWIM_TOPLOWER,
				WEAR_SHOW_TYPE.SWIM_BOTTOM
			};
			this.dicClothesID[8] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.GLOVE
			};
			this.dicClothesID[9] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.PANST
			};
			this.dicClothesID[10] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SOCKS
			};
			this.dicClothesID[11] = new WEAR_SHOW_TYPE[]
			{
				WEAR_SHOW_TYPE.SHOES
			};
		}

		// Token: 0x1700029C RID: 668
		// (get) Token: 0x06001AFB RID: 6907 RVA: 0x000ABEE8 File Offset: 0x000AA0E8
		// (set) Token: 0x06001AFC RID: 6908 RVA: 0x000ABEF0 File Offset: 0x000AA0F0
		public Human human { get; private set; }

		// Token: 0x1700029D RID: 669
		// (get) Token: 0x06001AFD RID: 6909 RVA: 0x000ABEFC File Offset: 0x000AA0FC
		// (set) Token: 0x06001AFE RID: 6910 RVA: 0x000ABF04 File Offset: 0x000AA104
		public CharFileStatus fileStatus { get; private set; }

		// Token: 0x1700029E RID: 670
		// (get) Token: 0x06001AFF RID: 6911 RVA: 0x000ABF10 File Offset: 0x000AA110
		public GameObject gameObject
		{
			get
			{
				return this.human.gameObject;
			}
		}

		// Token: 0x1700029F RID: 671
		// (get) Token: 0x06001B00 RID: 6912 RVA: 0x000ABF20 File Offset: 0x000AA120
		public Transform transform
		{
			get
			{
				return this.human.transform;
			}
		}

		// Token: 0x170002A0 RID: 672
		// (get) Token: 0x06001B01 RID: 6913 RVA: 0x000ABF30 File Offset: 0x000AA130
		public GameObject objBodyBone
		{
			get
			{
				return this.human.objBodyBone;
			}
		}

		// Token: 0x170002A1 RID: 673
		// (get) Token: 0x06001B02 RID: 6914 RVA: 0x000ABF40 File Offset: 0x000AA140
		public int sex
		{
			get
			{
				return (this.human.customParam.Sex != SEX.FEMALE) ? 0 : 1;
			}
		}

		// Token: 0x170002A2 RID: 674
		// (get) Token: 0x06001B03 RID: 6915 RVA: 0x000ABF60 File Offset: 0x000AA160
		public Animator animBody
		{
			get
			{
				return this.human.body.Anime;
			}
		}

		// Token: 0x170002A3 RID: 675
		// (get) Token: 0x06001B04 RID: 6916 RVA: 0x000ABF74 File Offset: 0x000AA174
		public GameObject[] objHairs
		{
			get
			{
				return this.human.hairs.objHairs;
			}
		}

		// Token: 0x170002A4 RID: 676
		// (get) Token: 0x06001B05 RID: 6917 RVA: 0x000ABF88 File Offset: 0x000AA188
		public int personality
		{
			get
			{
				return 0;
			}
		}

		// Token: 0x170002A5 RID: 677
		// (get) Token: 0x06001B06 RID: 6918 RVA: 0x000ABF8C File Offset: 0x000AA18C
		public float voicePitch
		{
			get
			{
				return 1f;
			}
		}

		// Token: 0x170002A6 RID: 678
		// (get) Token: 0x06001B07 RID: 6919 RVA: 0x000ABF94 File Offset: 0x000AA194
		public bool isVoicePlaying
		{
			get
			{
				return this.human.IsVoicePlaying();
			}
		}

		// Token: 0x170002A7 RID: 679
		// (get) Token: 0x06001B08 RID: 6920 RVA: 0x000ABFA4 File Offset: 0x000AA1A4
		public LookAtRotator eyeLookCtrl
		{
			get
			{
				return this.human.EyeLook;
			}
		}

		// Token: 0x170002A8 RID: 680
		// (get) Token: 0x06001B09 RID: 6921 RVA: 0x000ABFB4 File Offset: 0x000AA1B4
		public LookAtRotator neckLookCtrl
		{
			get
			{
				return this.human.NeckLook;
			}
		}

		// Token: 0x170002A9 RID: 681
		// (get) Token: 0x06001B0A RID: 6922 RVA: 0x000ABFC4 File Offset: 0x000AA1C4
		// (set) Token: 0x06001B0B RID: 6923 RVA: 0x000ABFCC File Offset: 0x000AA1CC
		public Expression expression { get; private set; }

		// Token: 0x06001B0C RID: 6924 RVA: 0x000ABFD8 File Offset: 0x000AA1D8
		public GameObject GetReferenceInfo(CharReference.RefObjKey _key)
		{
			return this.human.GetReferenceInfo(_key);
		}

		// Token: 0x06001B0D RID: 6925 RVA: 0x000ABFE8 File Offset: 0x000AA1E8
		public float GetShapeBodyValue(int _idx)
		{
			return this.human.customParam.body.shapeVals[_idx];
		}

		// Token: 0x06001B0E RID: 6926 RVA: 0x000AC004 File Offset: 0x000AA204
		public void PlayDynamicBoneBust(CharDefine.DynamicBoneKind _kind, bool _flag)
		{
			Female female = this.human as Female;
			if (female == null)
			{
				return;
			}
			if (_kind != CharDefine.DynamicBoneKind.BreastL)
			{
				if (_kind == CharDefine.DynamicBoneKind.BreastR)
				{
					female.body.bustDynamicBone_R.enabled = _flag;
				}
			}
			else
			{
				female.body.bustDynamicBone_L.enabled = _flag;
			}
		}

		// Token: 0x06001B0F RID: 6927 RVA: 0x000AC068 File Offset: 0x000AA268
		public void UpdateBustSoftnessAndGravity()
		{
		}

		// Token: 0x06001B10 RID: 6928 RVA: 0x000AC06C File Offset: 0x000AA26C
		public void Load(CustomParameter _param)
		{
			this.human.Load(_param, true);
		}

		// Token: 0x06001B11 RID: 6929 RVA: 0x000AC07C File Offset: 0x000AA27C
		public bool InitializeExpression(bool _enable = true)
		{
			string assetBundleName = "studio/info/00.unity3d";
			string assetName = (this.sex != 1) ? "cm_expression" : "cf_expression";
			this.expression = this.human.gameObject.AddComponent<Expression>();
			this.expression.LoadSetting(assetBundleName, assetName);
			this.expression.SetCharaTransform(this.human.gameObject.transform);
			this.expression.Initialize();
			this.expression.enable = _enable;
			return true;
		}

		// Token: 0x06001B12 RID: 6930 RVA: 0x000AC104 File Offset: 0x000AA304
		public void Reload()
		{
			this.human.Apply();
		}

		// Token: 0x06001B13 RID: 6931 RVA: 0x000AC114 File Offset: 0x000AA314
		public int GetEyesMaxPtn()
		{
			return (this.sex != 1) ? Singleton<Info>.Instance.dicMaleEye.Count : Singleton<Info>.Instance.dicFemaleEye.Count;
		}

		// Token: 0x06001B14 RID: 6932 RVA: 0x000AC148 File Offset: 0x000AA348
		public int GetEyesPtn()
		{
			return this.fileStatus.eyesPtn;
		}

		// Token: 0x06001B15 RID: 6933 RVA: 0x000AC158 File Offset: 0x000AA358
		public void ChangeEyesPtn(int _ptn)
		{
			this.fileStatus.eyesPtn = _ptn;
			Info.ExpressionInfo expressionInfo = (this.sex != 1) ? Singleton<Info>.Instance.dicMaleEye[_ptn] : Singleton<Info>.Instance.dicFemaleEye[_ptn];
			this.human.ExpressionPlay(0, expressionInfo.clip, 0.2f);
		}

		// Token: 0x06001B16 RID: 6934 RVA: 0x000AC1BC File Offset: 0x000AA3BC
		public int GetMouthMaxPtn()
		{
			return (this.sex != 1) ? Singleton<Info>.Instance.dicMaleMouth.Count : Singleton<Info>.Instance.dicFemaleMouth.Count;
		}

		// Token: 0x06001B17 RID: 6935 RVA: 0x000AC1F0 File Offset: 0x000AA3F0
		public int GetMouthPtn()
		{
			return this.fileStatus.mouthPtn;
		}

		// Token: 0x06001B18 RID: 6936 RVA: 0x000AC200 File Offset: 0x000AA400
		public void ChangeMouthPtn(int _ptn)
		{
			this.fileStatus.mouthPtn = _ptn;
			Info.ExpressionInfo expressionInfo = (this.sex != 1) ? Singleton<Info>.Instance.dicMaleMouth[_ptn] : Singleton<Info>.Instance.dicFemaleMouth[_ptn];
			this.human.ExpressionPlay(1, expressionInfo.clip, 0.2f);
		}

		// Token: 0x06001B19 RID: 6937 RVA: 0x000AC264 File Offset: 0x000AA464
		public void ChangeHohoAkaRate(float _rate)
		{
		}

		// Token: 0x06001B1A RID: 6938 RVA: 0x000AC268 File Offset: 0x000AA468
		public void ChangeLookEyesPtn(int _ptn, bool _force = false)
		{
			LookAtRotator.TYPE[] array = new LookAtRotator.TYPE[]
			{
				LookAtRotator.TYPE.FORWARD,
				LookAtRotator.TYPE.TARGET,
				LookAtRotator.TYPE.AWAY,
				LookAtRotator.TYPE.HOLD,
				LookAtRotator.TYPE.TARGET
			};
			this.eyeLookCtrl.ChangePtn(array[_ptn], _force);
			this.fileStatus.eyesLookPtn = _ptn;
		}

		// Token: 0x06001B1B RID: 6939 RVA: 0x000AC2A4 File Offset: 0x000AA4A4
		public void ChangeLookNeckPtn(int _ptn, bool _force = false)
		{
			LookAtRotator.TYPE[] array = new LookAtRotator.TYPE[]
			{
				LookAtRotator.TYPE.FORWARD,
				LookAtRotator.TYPE.TARGET,
				LookAtRotator.TYPE.NO,
				LookAtRotator.TYPE.HOLD
			};
			this.neckLookCtrl.ChangePtn(array[_ptn], _force);
			this.fileStatus.neckLookPtn = _ptn;
		}

		// Token: 0x06001B1C RID: 6940 RVA: 0x000AC2E0 File Offset: 0x000AA4E0
		public void ChangeEyesOpenMax(float _value)
		{
			this.fileStatus.eyesOpenMax = _value;
			this.human.blink.LimitMax = _value;
		}

		// Token: 0x06001B1D RID: 6941 RVA: 0x000AC300 File Offset: 0x000AA500
		public void SetEyesOpenRateForce(float _value)
		{
			this.fileStatus.eyesOpen = _value;
			this.human.OpenEye(_value);
		}

		// Token: 0x06001B1E RID: 6942 RVA: 0x000AC31C File Offset: 0x000AA51C
		public bool GetEyesBlinkFlag()
		{
			return this.fileStatus.eyesBlink;
		}

		// Token: 0x06001B1F RID: 6943 RVA: 0x000AC32C File Offset: 0x000AA52C
		public void ChangeEyesBlinkFlag(bool _flag)
		{
			this.fileStatus.eyesBlink = _flag;
			this.human.blink.Hold = !_flag;
		}

		// Token: 0x06001B20 RID: 6944 RVA: 0x000AC350 File Offset: 0x000AA550
		public bool LoadAnimation(string _bundlePath, string _fileName, bool _force = false)
		{
			if (null == this.animBody)
			{
				return false;
			}
			RuntimeAnimatorController runtimeAnimatorController = (!_force) ? CommonLib.LoadAsset<RuntimeAnimatorController>(_bundlePath, _fileName, false, string.Empty) : CommonLib.LoadForceAsset<RuntimeAnimatorController>(_bundlePath, _fileName, false, string.Empty);
			if (null == runtimeAnimatorController)
			{
				return false;
			}
			this.animBody.runtimeAnimatorController = runtimeAnimatorController;
			AssetBundleManager.UnloadAssetBundle(_bundlePath, false, null, false);
			return true;
		}

		// Token: 0x06001B21 RID: 6945 RVA: 0x000AC3BC File Offset: 0x000AA5BC
		public void AnimPlay(string _state)
		{
			this.animBody.Play(_state);
		}

		// Token: 0x06001B22 RID: 6946 RVA: 0x000AC3CC File Offset: 0x000AA5CC
		public void SetAnimatorParamFloat(string _param, float _value)
		{
			this.animBody.SetFloat(_param, _value);
		}

		// Token: 0x06001B23 RID: 6947 RVA: 0x000AC3DC File Offset: 0x000AA5DC
		public AnimatorStateInfo GetAnimatorStateInfo(int _layer)
		{
			return this.animBody.GetCurrentAnimatorStateInfo(_layer);
		}

		// Token: 0x06001B24 RID: 6948 RVA: 0x000AC3EC File Offset: 0x000AA5EC
		public void EnableExpressionCategory(int _category, bool _value)
		{
			this.expression.EnableCategory(_category, _value);
		}

		// Token: 0x06001B25 RID: 6949 RVA: 0x000AC3FC File Offset: 0x000AA5FC
		public void ChangeCoordinateType(CharDefine.CoordinateType _type)
		{
		}

		// Token: 0x06001B26 RID: 6950 RVA: 0x000AC400 File Offset: 0x000AA600
		public void LoadCoordinate(string _path)
		{
			this.human.LoadCoordinate(_path, 24);
		}

		// Token: 0x06001B27 RID: 6951 RVA: 0x000AC414 File Offset: 0x000AA614
		public void SetClothesState(int _id, byte _state)
		{
			if (this.sex == 1)
			{
				foreach (WEAR_SHOW_TYPE type in this.dicClothesID[_id])
				{
					this.human.wears.ChangeShow(type, (WEAR_SHOW)_state);
				}
			}
			else
			{
				Male male = this.human as Male;
				foreach (WEAR_SHOW_TYPE type2 in this.dicClothesID[_id])
				{
					male.SetWearsShow(type2, (WEAR_SHOW)_state);
				}
			}
			this.human.CheckShow();
		}

		// Token: 0x06001B28 RID: 6952 RVA: 0x000AC4B8 File Offset: 0x000AA6B8
		public void SetClothesStateAll(byte _state)
		{
			int[] source = new int[]
			{
				10,
				12,
				13
			};
			if (this.sex == 1)
			{
				for (int i = 0; i < 14; i++)
				{
					this.human.wears.ChangeShow((WEAR_SHOW_TYPE)i, (WEAR_SHOW)((!source.Contains(i)) ? _state : ((_state == 0) ? 0 : 2)));
				}
			}
			else
			{
				Male male = this.human as Male;
				for (int j = 0; j < 14; j++)
				{
					male.SetWearsShow((WEAR_SHOW_TYPE)j, (WEAR_SHOW)((!source.Contains(j)) ? _state : ((_state == 0) ? 0 : 2)));
				}
			}
			this.human.CheckShow();
		}

		// Token: 0x06001B29 RID: 6953 RVA: 0x000AC584 File Offset: 0x000AA784
		public bool IsClothesStateKind(int _id)
		{
			bool flag = false;
			foreach (WEAR_SHOW_TYPE type in this.dicClothesID[_id])
			{
				flag |= this.human.wears.IsEquiped(this.human.customParam, type);
			}
			return flag;
		}

		// Token: 0x06001B2A RID: 6954 RVA: 0x000AC5D8 File Offset: 0x000AA7D8
		public void ShowAccessory(int _id, bool _flag)
		{
			if (this.sex == 1)
			{
				this.human.accessories.SetShow(_id, _flag);
			}
			else
			{
				Male male = this.human as Male;
				male.SetAccessoryShow(_id, _flag);
			}
		}

		// Token: 0x04001DB9 RID: 7609
		private Dictionary<int, WEAR_SHOW_TYPE[]> dicClothesID;
	}
}
